#include "check_soa.h"
void addNameServers(char * nsList,int *nsNum,ns_msg handle,ns_sect section)
{
	int rrnum;
	ns_rr rr;
	int i,dup;

	for (rrnum = 0;rrnum < ns_msg_count(handle,section);rrnum++)
	{

		if (ns_parserr(&handle,section,rrnum,&rr)){
			fprintf(stderr,"ns_parserr: %s \n",strerror(errno));
		}

		if (ns_rr_type(rr) == ns_t_ns){
			nsList = (char *) malloc (MAXDNAME);
			if (nsList[*nsNum] ==NULL){
				(void) fprintf(stderr,"malloc failed \n");
				exit(1);
			}

			if (ns_name_uncompress(
						ns_msg_base(handle),
						ns_msg_end(handle),
						ns_rr_rdata(rr),
						nsList[*nsNum]，
						MAXDNAME）
								< 0){
					(void) fprintf(stderr,"ns_name_uncompress failed \n");
					exit(1);
					}

					for (i = 0) ,dup=0;(i< *nsNum) && !dup;i++)
						dup = ! strcasecmp(nsList[i],nsList[*nsNum]);
					if (dup)
						free (nsList[*nsNum]);
					else
						(*nsNum)++;
		}
	}
}
